package cn.itsource.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import cn.itsource.constants.RConst;
import cn.itsource.pojo.domain.CustomerCar;
import cn.itsource.mapper.CustomerCarMapper;
import cn.itsource.pojo.ro.CarInfoRo;
import cn.itsource.service.ICustomerCarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 客户车辆 服务实现类
 * </p>
 *
 * @author zls
 * @since 2024-07-08
 */
@Service
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements ICustomerCarService {

    @Override
    public void add(CarInfoRo carInfoRo) {
        Long loginId = Long.valueOf(StpUtil.getLoginId().toString());
        CustomerCar customerCar = new CustomerCar()
                .setCustomerId(loginId)
                .setCreateTime(new Date())
                .setId(IdUtil.createSnowflake(RConst.Num.INT_1,RConst.Num.INT_1).nextId())
                .setCarType(carInfoRo.getCarType())
                .setCarPlate(carInfoRo.getCarPlate())
                ;
        super.save(customerCar);
    }
}
